package com.binaryTree;

public class MinimumAbsoluteDifferenceinBST0305_530 {

    int min = Integer.MAX_VALUE;
    TreeNode pre;
    public int getMinimumDifference(TreeNode root) {
        if(root == null) return 0;
        traversal(root);
        return min;
    }

    private void traversal(TreeNode root) {
        if(root == null) return;
        traversal(root.left);
        if(pre!=null){
            min = Math.min(min,root.val-pre.val);
        }
        pre = root;
        traversal(root.right);
    }
}
